// Generated using webpack-cli https://github.com/webpack/webpack-cli

import CopyPlugin from "copy-webpack-plugin";
import path from "path";

const isProduction = process.env.NODE_ENV == "production";


const config = {
    entry: {
        "extensions/Sippreep.Extensions.NodeOffHack": "./src/index.ts",
    },
    output: {
        clean: true,
        path: path.resolve(__dirname, "dist"),
        filename: "[name].js",
    },
    plugins: [
        new CopyPlugin({
            patterns: [
                {
                    from: path.resolve(__dirname, "dts"),
                    to: path.resolve(__dirname, "dist", "dts"),
                },
                {
                    from: path.resolve(__dirname, "test"),
                    to: path.resolve(__dirname, "dist"),
                },
            ],
        }),
    ],
    module: {
        rules: [
            {
                test: /\.(ts|tsx)$/i,
                loader: "ts-loader",
                exclude: ["/node_modules/"],
            },
            {
                test: /\.css$/i,
                use: ["style-loader", "css-loader"],
            },
            {
                test: /\.(eot|svg|ttf|woff|woff2|png|jpg|gif)$/i,
                type: "asset",
            },
        ],
    },
    devServer: {
        port: 8090,
    },
    resolve: {
        extensions: [".tsx", ".ts", ".js"],
    },
    mode: "",
    devtool:"",

};

module.exports = () => {
    if (isProduction) {
        config.mode = "production";
        config.devtool = "nosources-source-map";
    } else {
        config.mode = "development";
        // config.devtool = "inline-source-map";
        config.devtool = "inline-source-map";
        // config.devtool = "hidden-nosources-source-map";
    }
    return config;
};
